package com.neu.service.impl;

import com.neu.constant.MaterialTypeEnum;
import com.neu.mapper.ArticleMapper;
import com.neu.pojo.Article;
import com.neu.pojo.Material;
import com.neu.service.ArticleService;
import com.neu.service.MaterialService;
import com.neu.vo.ArticleVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Resource
    private MaterialService materialService;

    @Override
    public ArticleVO queryArticleInfo(int id) {
        Article article = articleMapper.queryArticle(id);
        List<Material> list = materialService.list(id, MaterialTypeEnum.ARTICLE.type);
        return ArticleVO.builder().article(article).list(list).build();
    }
}
